﻿using System;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents a linebreak.
    /// </summary>
    [Serializable]
    [Standalone]
    public class Br : Element {
        /// <summary>
        /// Determines what items the linebreak should clear.
        /// </summary>
        public enum ClearChoices {
            /// <summary>
            /// Clear all floating objects to the left.
            /// </summary>
            Left,

            /// <summary>
            /// Clear all floating objects to the right.
            /// </summary>
            Right,

            /// <summary>
            /// Clear all floating objects on all sides.
            /// </summary>
            All,

            /// <summary>
            /// Clear no floating objects.
            /// </summary>
            None
        }

        private ClearChoices? _clear;

        /// <summary>
        /// Determines what floating objects to clear when breaking.
        /// </summary>
        [Obsolete("Deprecated in HTML4 - use CSS instead.")]
        public ClearChoices? Clear {
            get { return _clear; }
            set { _clear = value; }
        }

        /// <summary>
        /// Gets a formatted string of all local attributes of this element
        /// (not including the base attributes).
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's
        /// attribute data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            AttributeWriter.Write(sb, _clear, "clear", true);
        }
    }
}
